package com.leetcode.algorithm.y22.m08.w3;

import java.util.ArrayList;
import java.util.List;

/**
 * 1557. 可以到达所有点的最少点数目
 * 
 * https://leetcode.cn/problems/minimum-number-of-vertices-to-reach-all-nodes/
 * 
 * @author jie.deng
 *
 */
class Question1557Solution01 {
	
	public List<Integer> findSmallestSetOfVertices(int n, List<List<Integer>> edges) {
		List<Integer> list = new ArrayList<>();
		int[] in = new int[n];
		for (List<Integer> edge : edges) {
			in[edge.get(1)]++;
		}
		for (int i = 0; i < in.length; i++) {
			if (in[i] == 0) {
				list.add(i);
			}
		}
		return list;
	}
    
}